﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using My.ELibrary.Model.Search;
using My.ELibrary.Business.Search;
using My.ELibrary.Common;

public partial class Search_UC_ShowBookInfo : System.Web.UI.UserControl
{
    private int ModelId
    {
        get
        {
            if (Request["ModelId"] != null)
            {
                return int.Parse(Request["ModelId"].ToString());
            }
            return -1;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (ModelId == -1)
            return;
        ElibResBookModel book = ElibResBookBLL.GetInstance().SelectOne(ModelId);
        if (book != null)
        {
            ShowBookInfo(book);
        }
    }

    private void ShowBookInfo(ElibResBookModel book)
    {
        if (book == null)
            return;

        lblNameLocal.Text = EncodeForLabelShow(book.NameLocal);
        lblNameEn.Text = EncodeForLabelShow(book.NameEn);
        lblGroupOne.Text = book.GroupOne != 0 ? book.GroupOne.ToString() : string.Empty;
        lblGroupTwo.Text = book.GroupTwo != 0 ? book.GroupTwo.ToString() : string.Empty;
        lblGroupThree.Text = book.GroupThree != 0 ? book.GroupThree.ToString() : string.Empty;
        lblGroupFour.Text = book.GroupFour != 0 ? book.GroupFour.ToString() : string.Empty;
        lblSubject.Text = EncodeForLabelShow(book.Subject);
        lblSummary.Text = EncodeForLabelShow(book.Summary);
        lblKeyWords.Text = EncodeForLabelShow(book.Keywords);
        lblHeadLine.Text = EncodeForLabelShow(book.Headerline);
        lblAuthor1.Text = EncodeForLabelShow(book.Author1);
        lblAuthor2.Text = EncodeForLabelShow(book.Author2);
        lblAuthor3.Text = EncodeForLabelShow(book.Author3);
        lblBookDate.Text = book.BookDate != MyType.NullForDateTime ? book.BookDate.ToString() : string.Empty;
        //lblBookDate.Text = book.BookDate.ToString();
        lblPublish.Text = EncodeForLabelShow(book.Publisher);
        lblPublishDate.Text = book.PublishedDate != MyType.NullForDateTime ? book.PublishedDate.ToString() : string.Empty;
        //lblPublishDate.Text = book.PublishedDate.ToString();
        lblPrice.Text = book.Price != 0 ? book.Price.ToString() : string.Empty;
        lblCatalogue.Text = EncodeForLabelShow(book.CatalogueHtml);
    }

    private string EncodeForLabelShow(string strSourceFromDB)
    {
        if (!string.IsNullOrEmpty(strSourceFromDB))
        {
            return Server.HtmlDecode(strSourceFromDB);
        }
        return string.Empty;
    }
}
